import Axios from './http'
import {
  Message
} from 'element-ui'
// import { mapActions } from 'vuex'
import store from '../../store'
export default function getLogo () {
  if (store.state.logoInfo.length === 0) {
    Axios.post('/api/logo/getLogo', {
      domain: window.location.host
    }).then((data) => {
      if (data.data.code === '200') {
        store.dispatch('setLogoInfo', data.data.data)
      } else {
        Message({
          message: data.data.message,
          type: 'warning'
        })
      }
    }).catch((err) => {
      console.error(err)
      Message({
        message: '生意太火爆了, 请稍后再试',
        type: 'error'
      })
    })
  }
}

export function isMobile () {
  let mobileArr = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
  let isMobile = false
  for (let i = 0; i < mobileArr.length; i++) {
    if (navigator.userAgent.indexOf(mobileArr[i]) >= 0) {
      isMobile = true
      break
    }
  }
  return isMobile
}
